{
    This file is part of the Free Pascal run time library.
    Copyright (c) 2001 by Free Pascal development team

    This file implements all the base types and limits required
    for a minimal POSIX compliant subset required to port the compiler
    to a new OS.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 **********************************************************************}

{Platform specific information}

type
 THandle = longint;
 
 TResult = LongWord;
  
 TThreadID = THandle;

 PRTLCriticalSection = ^TRTLCriticalSection;
 TRTLCriticalSection = record
  lock: longint;
 end;

const
 R_OK = 1;
 R_ERROR = 0;
 
 InvalidHandle = THandle(-1);

type
 TFileFlags = set of(fmOpenRead, fmOpenWrite, fmOpenCreate);
 
 TFileAttributes = set of(faDirectory, faReadOnly);
 
 TFileAge = longword;
 
 PSearchBlock = ^TSearchBlock;
 TSearchBlock = packed record
  Filename: pchar;
  FileAttr: TFileAttributes;
  FileSize: int64;
  FileAge: TFileAge;
  
  Handle: THandle;
 end;

 PThreadPriority = ^TThreadPriority;
 TThreadPriority = (tpPaused, tpLow, tpNormal, tpHigh, tpRealtime);

function OpenFile(filename: pchar; filemode: TFileFlags): THandle;
procedure CloseFile(handle: THandle);
function ReadFile(handle: THandle; buffer: Pointer; Size: int64): int64;
function WriteFile(handle: THandle; buffer: Pointer; Size: int64): int64;
function SeekFile(handle: THandle; Position: int64; SearchOffset: longword): int64;
function FindFirst(searchBlock: PSearchBlock): longint;
function FindNext(searchBlock: PSearchBlock): longint;
function FindClose(searchBlock: PSearchBlock): longint;
function FileSize(Handle: THandle): int64;
function FileAge(Handle: THandle): TFileAge;
function SetFileAge(Handle: THandle; NewAge: TFileAge): longint;

function CreateThread(Process: THandle; EntryPoint, Data: Pointer; StackSize: PtrUInt; ThreadPriority: TThreadPriority): THandle;
function DestroyThread(ThreadHandle: THandle): TResult;

function SleepThread(ThreadHandle: THandle): TResult;
function WakeupThread(ThreadHandle: THandle): TResult;
function SetThreadPriority(ThreadHandle: THandle; NewPriority: TThreadPriority): TResult;
function GetThreadPriority(ThreadHandle: THandle; NewPriority: PThreadPriority): TResult;
function GetCurrentThreadHandle: THandle;